package com.example.wlzz.controller;
import java.io.InputStream;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.example.wlzz.api.ConfigAPI;
import com.example.wlzz.api.FileApi;
import com.example.wlzz.constant.RedisConstant;
import com.example.wlzz.dto.*;
import com.example.wlzz.enums.ResultEnum;
import com.example.wlzz.form.CrawlerForm;
import com.example.wlzz.repository.DepartmentWebRepository;
import com.example.wlzz.repository.mongoRepository.KlassRepository;
import com.example.wlzz.service.UserInfoService;
import com.example.wlzz.utils.*;
import com.example.wlzz.vo.CodeVO;
import com.example.wlzz.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.util.StringUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.*;


@RestController
@RequestMapping("/nanjingCrawler")
@Slf4j
@Api(tags = "南京信息工程大学爬虫模块")
public class NanjingController {
    @Autowired
    private ConfigAPI configAPI;
    @Autowired
    private FileApi fileApi;
    @Autowired
    private UserInfoService userInfoService;
    @Autowired
    private DepartmentWebRepository departmentWebRepository;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private KlassRepository klassRepository;
    @PostMapping("/first")
    @ApiOperation("第一步：进入这里获取登陆的cookie和验证码")
    public ResultVO first(@ApiParam("token") @RequestParam("token") String token){
        try {
            CodeVO codeVO = new CodeVO();
            codeVO.setCode("");
            Map<String,String> headMap = new HashMap<>();
            headMap.put("Connection","keep-alive");
            headMap.put("Host","wlkt.nuist.edu.cn");
            //text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
            headMap.put("Upgrade-Insecure-Requests","1");
            headMap.put("Accept-Encoding","gzip, deflate");
            headMap.put("Accept-Language","zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
            headMap.put("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
            headMap.put("User-Agent", "Mozilla/5.0 (Windows NT 6.1; W…) Gecko/20100101 Firefox/62.0");
                  //已过期的网址，会重定向有效的网址         http://wlkt.nuist.edu.cn/
            Connection.Response demo = Jsoup.connect("http://wlkt.nuist.edu.cn/")
                                            .ignoreContentType(true)
                                            .method(Connection.Method.GET)
                                            .followRedirects(false)
                                            .ignoreHttpErrors(true)
                                            .headers(headMap)
                                            .timeout(10000)
                                            .execute();
            System.out.println(demo.statusCode());
            //获取真正验证码的内容
            if(demo.statusCode()==302){
                //模拟浏览器访问一下主页
                Connection.Response indexResult = Jsoup.connect("http://wlkt.nuist.edu.cn" + demo.header("Location"))
                        .ignoreContentType(true)
                        .method(Connection.Method.GET)
                        .ignoreHttpErrors(true)
                        .headers(headMap)
                        .timeout(10000)
                        .execute();
                if(indexResult.statusCode()==200){   //访问一下首页，争取模拟浏览器
                    redisTemplate.opsForValue().set(String.format(RedisConstant.SYS_KLASS_NANJING,"login"), indexResult.parse().getElementById("__VIEWSTATE").val(), RedisConstant.EXPIRE, TimeUnit.SECONDS);
                    Thread.sleep(300);   //伪装一波延迟
                    String redisRealUrl = "http://wlkt.nuist.edu.cn" + demo.header("Location");
                    String realUrl ="http://wlkt.nuist.edu.cn" + demo.header("Location").replace("default.aspx", "yzm.aspx");
                    System.out.println(realUrl);
                    Connection realConn = Jsoup.connect(realUrl);
                    Connection.Response realConnResp = realConn.ignoreContentType(true)
                            .method(Connection.Method.GET)
                            .followRedirects(false)
                            .ignoreHttpErrors(true)
                            .headers(headMap)
                            .timeout(10000)
                            .execute();
                    //将真实地址放入缓存   -->时间为5分钟
                    String tokenValue = redisTemplate.opsForValue().get(String.format(RedisConstant.LOGIN_SUCCESS_TOKEN, token));
                    redisTemplate.opsForValue().set(String.format(RedisConstant.NAN_J_CODE, tokenValue), redisRealUrl, RedisConstant.ADMIN_EXPIRE, TimeUnit.SECONDS);
                    //将图片保存在本地服务器
                    InputStream bufferedInputStream = realConnResp.bodyStream();
                    String fileName = KeyUtil.genUniqueKey();
                    NanJingFileToCode.savePic(bufferedInputStream,fileApi.getSave_url(),fileName);
                    codeVO.setCodeImgUrl("http://"+configAPI.getName()+"/wlzzUser/"+"getCode?number="+fileName);
                    codeVO.setCookies("no cookie");
                    return ResultVOUtil.success(codeVO);
                }else{
                    return  first(token);  //重新走一遍
                }
            }else{
                return  first(token);  //重新走一遍
            }
        }catch (Exception e){
            e.printStackTrace();
            if(e instanceof java.net.SocketTimeoutException){
              log.warn("【南京信息工程大学First】 获取基本登录信息失败，正在重新获取");
              return first(token);  //重新走一遍
            }
            log.error("【南京信息工程大学First】 获取基本登录信息失败,出现未知异常");
            return ResultVOUtil.error(ResultEnum.GET_CLASS_ERROR.getCode(),ResultEnum.GET_CLASS_ERROR.getMessage());
        }
    }

    @PostMapping("/second")
    @ApiOperation("登录")
    public ResultVO second(@Valid CrawlerForm crawlerForm , BindingResult bindingResult, @ApiParam("token") @RequestParam("token") String token){
        if(bindingResult.hasErrors()) {
            return ResultVOUtil.error(ResultEnum.LOGIN_SCHOOL_ERROR.getCode(),ResultEnum.LOGIN_SCHOOL_ERROR.getMessage());
        }
        Map<String, String> datas = new HashMap<>();  //参数
        //无用参数
        //去redis查询
        String login_VIEW = redisTemplate.opsForValue().get(String.format(RedisConstant.SYS_KLASS_NANJING, "login"));
        datas.put("__VIEWSTATE",login_VIEW);
        datas.put("__VIEWSTATEGENERATOR","CA0B0334");
        datas.put("TextBox1",crawlerForm.getSno().trim());
        datas.put("TextBox2",crawlerForm.getPasswd().trim());
        datas.put("TxtYZM",crawlerForm.getCode());
        datas.put("js","RadioButton3");
        datas.put("Button1","登录");

        String tokenValue = redisTemplate.opsForValue().get(String.format(RedisConstant.LOGIN_SUCCESS_TOKEN, token));
        String redisUrl = redisTemplate.opsForValue().get(String.format(RedisConstant.NAN_J_CODE, tokenValue));
        if (StringUtils.isEmpty(redisUrl)) {  //查询redis
            log.error("【南京信息工程大学爬虫】没有获取第一步的验证码或者已失效，Redis中查不到重定向后的值");
            return ResultVOUtil.error(ResultEnum.CODE_NO_EXIST.getCode(),ResultEnum.CODE_NO_EXIST.getMessage());
        }
        Connection con2 = Jsoup
                .connect(redisUrl);
        Map<String,String> headMap = new HashMap<>();
        headMap.put("Connection","keep-alive");
        headMap.put("Host","wlkt.nuist.edu.cn");
        //text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
        headMap.put("Upgrade-Insecure-Requests","1");
        headMap.put("Accept-Encoding","gzip, deflate");
        headMap.put("Accept-Language","zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
        headMap.put("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
        headMap.put("User-Agent", "Mozilla/5.0 (Windows NT 6.1; W…) Gecko/20100101 Firefox/62.0");
        headMap.put("Referer",redisUrl);  //模拟浏览器带上上一个跳转页面
        Connection.Response login;
        try {
            // 设置cookie和post上面的map数据
            login = con2.ignoreContentType(true)
                    .method(Connection.Method.POST)
                    .headers(headMap)
                    .data(datas)
                    .followRedirects(false)
                    .timeout(10000)
                    .ignoreHttpErrors(true)
                    .execute();

        }catch (Exception e){
            e.printStackTrace();
            if(e instanceof java.net.SocketTimeoutException){
                log.warn("【南京信息工程大学登录】 登录超时，正在重新进行登录");
                return second(crawlerForm,bindingResult,token);  //重新走一遍
            }
            log.error("【南京信息工程大学登录】 登录异常，result={}",crawlerForm);
            return ResultVOUtil.error(ResultEnum.SNO_ERROR.getCode(), ResultEnum.SNO_ERROR.getMessage());
        }
        //document.getElementById("__VIEWSTATEGENERATOR").val().equalsIgnoreCase("CA0B0334");
        System.out.println("登录成功状态码："+login.statusCode());
        if(login.statusCode()==302){  //登陆成功
            if(StringUtils.isEmpty(login.cookie("MYWEBAPP.ASPXAUTH"))){
                return second(crawlerForm,bindingResult,token);  //重新走一遍，说明并没有登录成功。
            }
            log.info("恭喜登录成功 result={}",crawlerForm);
            userInfoService.alterSnoAndSnoPassword(crawlerForm.getSno(),crawlerForm.getPasswd(),token);//更改用户的学号和密码
            CookieDTO cookieDTO = new CookieDTO();
            cookieDTO.setCookies("MYWEBAPP.ASPXAUTH"+"="+login.cookie("MYWEBAPP.ASPXAUTH"));
            return ResultVOUtil.success(cookieDTO);
            //   return ResultVOUtil.success(crawlerForm.getCookie());
        }else{
            return ResultVOUtil.error(ResultEnum.SNO_ERROR.getCode(), ResultEnum.SNO_ERROR.getMessage());
        }
    }

    @PostMapping("/getNowClass")
    @ApiOperation("获得当前学期课表")
    public ResultVO getNowClass(@ApiParam("token") @RequestParam("token") String token,
                                @RequestParam("cookie") String cookie){
        log.warn("cookie={}",cookie);
        Map<String,String> cookies = new HashMap<>();
        String[] array = cookie.split("=");
        cookies.put(array[0],array[1]);
        String tokenValue = redisTemplate.opsForValue().get(String.format(RedisConstant.LOGIN_SUCCESS_TOKEN, token));
        String redisUrl = redisTemplate.opsForValue().get(String.format(RedisConstant.NAN_J_CODE, tokenValue));
        Map<String,String> headMap = new HashMap<>();
        headMap.put("Connection","keep-alive");
        headMap.put("Host","wlkt.nuist.edu.cn");
        //text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
        headMap.put("Upgrade-Insecure-Requests","1");
        headMap.put("Accept-Encoding","gzip, deflate");
        headMap.put("Accept-Language","zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
        headMap.put("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
        headMap.put("User-Agent", "Mozilla/5.0 (Windows NT 6.1; W…) Gecko/20100101 Firefox/62.0");
        headMap.put("Referer",redisUrl.replace("default.aspx", "student/xsmmwh.aspx"));  //模拟浏览器带上上一个跳转页面
        if (StringUtils.isEmpty(redisUrl)) {  //查询redis
            log.error("【南京信息工程大学爬虫】没有获取第一步的验证码或者已失效，Redis中查不到重定向后的值");
            return ResultVOUtil.error(ResultEnum.CODE_NO_EXIST.getCode(),ResultEnum.CODE_NO_EXIST.getMessage());
        }
        // 设置cookie和post上面的map数据
        try {
            Connection.Response klassIndex =  Jsoup.connect( redisUrl.replace("default.aspx","").trim()+"public/kebiaoall.aspx")
                    .headers(headMap)
                    .ignoreContentType(true)
                    .method(Connection.Method.GET)
                    .cookies(cookies)
                    .timeout(10000)
                    .ignoreHttpErrors(true)
                    .execute();

            Document document = klassIndex.parse(); // 这里就是得到HTML文本
       //     System.out.println(document.toString());
            Element tables = document.getElementById("TABLE1");   //得到当前table
            // System.out.println(tables.toString());
            Elements trElements = tables.getElementsByTag("tr");
            List<NewKlassContent> newKlassContentList = new ArrayList<>();
            for (int i = 1; i < trElements.size() - 1; i++) { // 一行一行来
                Elements tdElements = trElements.get(i).select("td"); // 对每一行的列进行操作
                for (int j = 1; j < tdElements.size(); j++) {
                    if("".equals(tdElements.get(j).text())) {
                        continue;
                    }
                    System.out.println(tdElements.get(j).text());
                    NewKlassContent klassContent = new NewKlassContent();
                    klassContent.setStart(2*i-1);
                    klassContent.setStep(2);
                    klassContent.setDay(j);
                    String arrayStr[] = tdElements.get(j).text().split("◇");
                    klassContent = getKlassContent(klassContent,arrayStr);
                     //如果有两种课。
                    if(tdElements.get(j).text().indexOf("◆")!=-1){
                            String[]  secondTdElement = tdElements.get(j).text().split("◆");
                            String secondTdKlass = secondTdElement[1];
                            NewKlassContent secondNewKlassContent = new NewKlassContent();
                            secondNewKlassContent.setStart(2*i-1);
                            secondNewKlassContent.setStep(2);
                            secondNewKlassContent.setDay(j);
                            String secondArrayStr[] = secondTdKlass.split("◇");
                            secondNewKlassContent = getKlassContent(secondNewKlassContent,secondArrayStr);
                            newKlassContentList.add(secondNewKlassContent);
                    }
                    newKlassContentList.add(klassContent);
//                    KlassForUser klassForUser = new KlassForUser();
//                    //去redis查询
//                    String tokenValue = redisTemplate.opsForValue().get(String.format(RedisConstant.LOGIN_SUCCESS_TOKEN, token));
//                    klassForUser.set_id(tokenValue);
//                    klassForUser.setKlassContent(newKlassContentList);
//                    klassRepository.save(klassForUser);
                }
            }
            return ResultVOUtil.success(newKlassContentList);
        }catch (Exception e){
            e.printStackTrace();
            return ResultVOUtil.error(ResultEnum.GET_CLASS_ERROR.getCode(),ResultEnum.GET_CLASS_ERROR.getMessage());
        }
    }
    @PostMapping("/getDepartment")
    @ApiOperation("获得南京信息工程大学的院系")
    public ResultVO getDepartment(@ApiParam("token") @RequestParam("token") String token){
        return ResultVOUtil.success(departmentWebRepository.findBySchoolId("3"));
    }

    @PostMapping("/getDepartmentForMajor")
    @ApiOperation("获得南京信息工程大学的专业")
    public ResultVO getDepartmentForMajor(@ApiParam("token") @RequestParam("token") String token,
                                          @RequestParam("cookie") String cookie,
                                          @RequestParam("yuanxi") String department,
                                          @ApiParam("上课年级-->年级，如2016，2017，2018") @RequestParam(value = "nj") String nj){
        Map<String,String> cookies = new HashMap<>();
        String[] array = cookie.split("=");
        cookies.put(array[0],array[1]);
        Map<String,String> headMap = new HashMap<>();
        headMap.put("Connection","keep-alive");
        headMap.put("Host","wlkt.nuist.edu.cn");
        headMap.put("Upgrade-Insecure-Requests","1");
        headMap.put("Accept-Encoding","gzip, deflate");
        headMap.put("Accept-Language","zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
        headMap.put("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
        headMap.put("User-Agent", "Mozilla/5.0 (Windows NT 6.1; W…) Gecko/20100101 Firefox/62.0");
       // 设置cookie和post上面的map数据

        String tokenValue = redisTemplate.opsForValue().get(String.format(RedisConstant.LOGIN_SUCCESS_TOKEN, token));
        String redisUrl = redisTemplate.opsForValue().get(String.format(RedisConstant.NAN_J_CODE, tokenValue));
        if (StringUtils.isEmpty(redisUrl)) {  //查询redis
            log.error("【南京信息工程大学爬虫】没有获取第一步的验证码或者已失效，Redis中查不到重定向后的值");
            return ResultVOUtil.error(ResultEnum.CODE_NO_EXIST.getCode(),ResultEnum.CODE_NO_EXIST.getMessage());
        }
        try {
            Connection.Response login =  Jsoup.connect( redisUrl.replace("default.aspx","student/xsjbxx.aspx"))
                    .headers(headMap)
                    .ignoreContentType(true)
                    .method(Connection.Method.GET)
                    .cookies(cookies)
                    .timeout(15000)
                    .ignoreHttpErrors(true)
                    .execute();
            Document indexDocument = login.parse(); // 先获取进入班级选课页面
            List<MajorKlass> majorKlassList = new ArrayList<>();
            Elements tableElements =   indexDocument.getElementsByTag("table");
            MajorKlass majorKlass = new MajorKlass();
            majorKlass.setDm(KeyUtil.genUniqueKey());
            majorKlass.setDmmc(tableElements.get(2).getElementsByTag("tr").get(3).getElementsByTag("td").get(3).text());
            majorKlassList.add(majorKlass);
            return ResultVOUtil.success(majorKlassList);
        }catch (Exception e){
            e.printStackTrace();
            return ResultVOUtil.error(ResultEnum.GET_MAJOR_ERROR.getCode(),ResultEnum.GET_MAJOR_ERROR.getMessage());
        }
    }

    @PostMapping("/getGrade")
    @ApiOperation("根据学期获取成绩")
    public ResultVO getGrade(@ApiParam("token") @RequestParam("token") String token,
                             @ApiParam("日期-例子:<br>2017-2018-2<br>2017-2018-1<br>2018-2019-1") @RequestParam(value = "xnxqh",defaultValue = "") String xnxqh,
                             @RequestParam("cookie") String cookie) {
        String[] riqi =  xnxqh.split("-");
        if(riqi.length!=3){
            return ResultVOUtil.error(ResultEnum.DATA_ERROR.getCode(),ResultEnum.DATA_ERROR.getMessage());
        }
        String tokenValue = redisTemplate.opsForValue().get(String.format(RedisConstant.LOGIN_SUCCESS_TOKEN, token));
        String redisUrl = redisTemplate.opsForValue().get(String.format(RedisConstant.NAN_J_CODE, tokenValue));
        if (StringUtils.isEmpty(redisUrl)) {  //查询redis
            log.error("【南京信息工程大学爬虫】没有获取第一步的验证码或者已失效，Redis中查不到重定向后的值");
            return ResultVOUtil.error(ResultEnum.CODE_NO_EXIST.getCode(),ResultEnum.CODE_NO_EXIST.getMessage());
        }
        String nian_xueqi = riqi[0]+"-"+riqi[1];
        String xueqi = riqi[2];
        String[] array = cookie.split("=");
        Map<String,String> cookies = new HashMap<String,String>();
        cookies.put(array[0],array[1]);
//        redisUrl.replace("default.aspx","student/chengji.aspx")
        Connection con = Jsoup.connect( redisUrl.replace("default.aspx","student/chengji.aspx"));
        con.header("User-Agent",
                "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0");// 配置模拟浏览器
        Connection.Response rs ;
        try {
            rs = con.ignoreContentType(true)
                    .method(Connection.Method.GET)
                    .ignoreHttpErrors(true)
                    .cookies(cookies)
                    .execute();// 获取响应
            Document document =  rs.parse();
            Element element = document.getElementById("GridView1");
            Elements trElements = element.getElementsByTag("tr");
            List<CrawlerGradeDTO> crawlerGradeDTOs = new ArrayList<>();
            CrawlerResultDTO crawlerResultDTO = new CrawlerResultDTO();
            for(int i = 1; i<trElements.size();i++) {
                Elements  tdElements = trElements.get(i).getElementsByTag("td");
                if(tdElements.get(0).text().trim().equals(nian_xueqi)&&tdElements.get(1).text().trim().equals(xueqi)){
                    CrawlerGradeDTO crawlerGradeDTO = new CrawlerGradeDTO();
                    crawlerGradeDTO.setKlassName(tdElements.get(2).text());
                    crawlerGradeDTO.setKlassType(tdElements.get(3).text());
                    crawlerGradeDTO.setGrade(tdElements.get(4).text());
                    crawlerGradeDTO.setCredit(tdElements.get(7).text());
                    crawlerGradeDTOs.add(crawlerGradeDTO);
                }
            }
            Elements tableElements = document.getElementsByTag("table");
            String result = tableElements.get(5).text();
            crawlerResultDTO.setCrList(crawlerGradeDTOs);
            crawlerResultDTO.setG_Credit(result.substring(result.indexOf("最低毕业学分:")+7,result.indexOf(";其中")));
            crawlerResultDTO.setM_Credit(result.substring(result.indexOf("共获学分:")+5,result.length()-1));
            return ResultVOUtil.success(crawlerResultDTO);
        }catch(Exception e){
            e.printStackTrace();
            return ResultVOUtil.error(ResultEnum.LOGIN_SCHOOL_ERROR.getCode(),ResultEnum.LOGIN_SCHOOL_ERROR.getMessage());
        }
    }
    public static NewKlassContent getKlassContent(NewKlassContent klassContent,String[] arrayStr){
        klassContent.setName(arrayStr[0]);
        if(arrayStr[0].indexOf("英语")!=-1|arrayStr[0].indexOf("体育")!=-1) {
            List<Integer> listTemp = Stream.iterate(1, item -> item + 1).limit(18).collect(Collectors.toList());
            klassContent.setWeekList(listTemp);
            klassContent.setRoom(arrayStr[1]);
            klassContent.setTeacher("");
        }else {
            klassContent.setTeacher(arrayStr[1].substring(0, arrayStr[1].indexOf("(")));
            if (arrayStr.length > 3) {   //如果小于这个表明没有地址
                klassContent.setRoom(arrayStr[2] + "◇" + arrayStr[3]);
                List<Integer> weekList = new ArrayList<>();
                String listStr = arrayStr[1].substring(arrayStr[1].indexOf("(") + 1, arrayStr[1].indexOf(")"));
                if (arrayStr[4].substring(0, 1).indexOf("单") != -1) {
                    String[] datelistArray = listStr.split("-");
                    for (int z = Integer.valueOf(datelistArray[0]); z <= Integer.valueOf(datelistArray[1]); z++) {
                        if (2 * z - 1 <= Integer.valueOf(datelistArray[1])) {
                            weekList.add(2 * z - 1);  //1,3,5,7,9...
                        }
                    }
                    klassContent.setWeekList(weekList);
                } else if (arrayStr[4].substring(0, 1).indexOf("双") != -1) {
                    String[] datelistArray = listStr.split("-");
                    for (int z = Integer.valueOf(datelistArray[0]); z <= Integer.valueOf(datelistArray[1]); z++) {
                        if (2 * z <= Integer.valueOf(datelistArray[1])) {
                            weekList.add(2 * z);  //2.4.6.8.10...
                        }
                    }
                    klassContent.setWeekList(weekList);
                } else {
                    klassContent.setWeekList(StrToListForIntUtil.getList(arrayStr[1].substring(arrayStr[1].indexOf("(") + 1, arrayStr[1].indexOf(")"))));
                }
            } else {    //说明没有地点  如： 古代名剧鉴赏（网络课程）◇网络通修教师6(5-15)◇{910节}
                klassContent.setWeekList(StrToListForIntUtil.getList(arrayStr[1].substring(arrayStr[1].indexOf("(") + 1, arrayStr[1].indexOf(")"))));
            }
        }
          return klassContent;
    }
}
